<template>
  <div class="md:flex">
    <template v-for="(item, index) in growCardList" :key="item.id">
      <Card
        size="small"
        :loading="loading"
        :title="item.dataName"
        class="md:w-1/4 w-full !md:mt-0 !mt-4"
        :class="[index + 1 < 4 && '!md:mr-4']"
        :canExpan="false"
      >
        <template #extra>
          <Tag color="orange">{{ item.dataYear }}年</Tag>
        </template>

        <div class="py-4 px-4 flex justify-between">
          <CountTo :suffix="item.dataUnit" :startVal="0" :endVal="Number(item.dataValue)" class="text-2xl" />
          <Icon :icon="iconList[index]" :size="40" />
        </div>

        <div class="p-2 px-4 flex justify-between">
          <span>最后更新时间</span>
          <span>{{ item.updateTime }}</span>
        </div>
      </Card>
    </template>
    <Card size="small" :loading="loading" title="当月数据统计" class="md:w-1/4 w-full !md:mt-0 !mt-4" :canExpan="false">
      <template #extra>
        <Icon icon="month|svg" :size="20" />
      </template>

      <div class="py-4 px-4 flex">
        <div class="flex w-full" style="flex-direction: column; font-size: 14px; font-weight: 500">
          <div class="flex justify-between" style="align-items: center">
            <span>热水消费金额：</span>
            <span style="font-size: 20px; font-weight: 600">{{ dataMonth?.Water_amount_everymonth }}元</span>
          </div>
          <div class="flex justify-between" style="align-items: center">
            <span>宿舍充电金额：</span>
            <span style="font-size: 20px; font-weight: 600">{{ dataMonth?.Electric_EveryMonth_AllMoney }}元</span>
          </div>
        </div>
      </div>
    </Card>
  </div>
</template>
<script lang="ts" setup>
  import { CountTo } from '/@/components/CountTo/index';
  import { Icon } from '/@/components/Icon';
  import { Tag, Card } from 'ant-design-vue';
  import { ref } from 'vue';
  import { Month, Item } from '../data';
  defineProps({
    loading: {
      type: Boolean,
    },
    growCardList: {
      type: Array<Item>,
    },
    dataMonth: {
      type: Object as PropType<Month>,
    },
  });

  const iconList = ref<string[]>(['total-sales|svg', 'visit-count|svg', 'transaction|svg']);
</script>
